'use strict';

/**
 * Created by twer on 15/3/24.
 */
angular.module('friend')
    .factory('FriendQueryService', [
        '$resource',
        'RootPathConstant',
        function ($resource, RootPathConstant) {
            return $resource(RootPathConstant + '/friendship/:userId/friends', {}, {
                query: {method: 'GET', isArray: true}
            });
        }])

    .factory('FriendRequestService', [
        '$resource',
        'RootPathConstant',
        function ($resource, RootPathConstant) {
            return $resource(RootPathConstant + '/friendship', {}, {
                request: {method: 'POST'},
                reject: {method: 'PUT'}
            });
        }])

    .factory('FriendConfirmService', [
        '$resource',
        'RootPathConstant', function ($resource, RootPathConstant) {
            return $resource(RootPathConstant + '/friendship/requester/:requesterId/acceptor/:acceptorId', {}, {
                confirm: {method: 'PUT'},
                remove: {method: 'DELETE'}
            });
        }])

    .factory('FriendAddModalService', ['btfModal', function (btfModal) {
        return btfModal({
            controller: 'FriendAddRequestCtrl',
            controllerAs: 'friendModal',
            templateUrl: 'views/friend/friend_add.html'
        });
    }]);
